package P1.gaojingdu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * @date:2022/10/23
 * @author:LdLtd
 * @name:c=A/b,商是C，余数是r
 */
public class Divide {
    static int r = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
                int b = sc.nextInt();
        List<Integer> A = new ArrayList<>();
        for (int i = a.length() - 1; i >= 0; i--) A.add(a.charAt(i) - '0');
        List<Integer> C=div(A,b);
        for (int i = C.size()-1; i >=0; i--) {
            System.out.print(C.get(i));
        }
        System.out.println("\n"+r);
    }
    public static List<Integer> div(List<Integer> A,int b){
        List<Integer>C =new ArrayList<>();
        for(int i=A.size()-1;i>=0;i--){
            r=r*10+A.get(i);
            C.add(r/b);
            r%=b;
        }
        //为保证和其余方法统一，将C翻转过来
        Collections.reverse(C);
        while(C.size()>1&&C.get(C.size()-1)==0) C.remove(C.size()-1);
        return  C;
    }

}
